package com.heima.wemedia.scan.runner;

import com.heima.utils.common.SensitiveWordUtil;
import com.heima.wemedia.scan.dao.WmSensitiveDao;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;

@Component
@Slf4j
public class WmNewsApplicationRunner implements ApplicationRunner {

    @Resource
    private WmSensitiveDao wmSensitiveDao;

    @Override
    public void run(ApplicationArguments args) throws Exception {
        log.info("spring boot项目启动完成--------------------");
        //1. 查询数据库中的敏感词列表
        List<String> words = wmSensitiveDao.findSensitiveList();
        //2. 基于敏感词列表初始化DFA结构
        SensitiveWordUtil.initMap(words);
    }
}